<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
    <jsp:include page="../common/common.jsp"/>
    <link href="${path}/assets/css/weixin/appmsg.css" rel="stylesheet" type="text/css"/>
</head>
<body class="page-header-fixed page-sidebar-fixed">
<jsp:include page="../common/header.jsp"/>
<div class="clearfix">
</div>
<div class="page-container">
<div class="page-sidebar-wrapper"><jsp:include page="../common/menu.jsp"/></div>
<div class="page-content-wrapper">
<div class="page-content">
<div class="row">
<div class="col-md-12">
<form class="form-horizontal form-row-seperated" action="${path}/article/upd">
<div class="portlet box purple">
<div class="portlet-title">
    <div class="caption">
        <i class="fa fa-shopping-cart"></i>添加单图文消息
    </div>
    <div class="actions btn-set">
        <button type="button" id="btnSave" class="btn blue"><i class="fa fa-check"></i> 保存</button>
        <a href="javascript:location.reload();" class="btn green"><i class="fa fa-reply"></i> 重置</a>
    </div>
</div>
<div class="portlet-body">
<div class="tabbable">
<div class="tab-content no-space">
<div class="tab-pane active" id="tab_general">
<div class="form-body">

<div class="form-group">
<div class="row">
<div class="col-md-5 msg-preview" id="nrdiv1">
    <div class="msg-item-wrapper" relid="">
        <div id="appmsgItem1" class="msg-item">
            <h4 class="msg-t">
                <span class="i-title m-title" rel="title"></span>
            </h4>

            <p class="msg-meta">
                <span class="msg-date">2014-04-09</span>
            </p>

            <div class="cover">
                <img class="i-img m-img" src="${path}/assets/img/blog/3.jpg"
                     tppabs="http://www.keenthemes.com/preview/metronic_admin/assets/img/blog/3.jpg"
                     style="width: 440px;height: 180px;">
            </div>
            <p class="msg-text m-desc" rel="desc"></p>

            <div rel="con" class="m-con" style="display: none;"></div>
            <div rel="url" class="m-url" style="display: none;"></div>
        </div>
        <div class="msg-hover-mask"></div>
        <div class="msg-mask">
            <span class="dib msg-selected-tip"></span>
        </div>
    </div>
</div>
<div class="col-md-7">
<div class="msg-editer-wrapper">
<div class="msg-editer">
<form id="appmsg-form" class="form">
<div class="control-group">
    <label class="control-label">标题</label><span
        class="maroon">*</span><span
        class="help-inline">(必填,不能超过64个字)</span>

    <div class="controls">
        <input type="text" value="" id="title" class="span5"
               style="width: 482px;" name="title">
    </div>
</div>
<div class="control-group" id="picsethere"></div>
<div class="control-group">
    <label class="control-label">封面</label><span
        class="maroon">*</span><span class="help-inline">(必须上传一张图片)</span>

    <div class="controls">
        <div class="cover-area" style="height: 40px;overflow: hidden;">
            <div class="cover-hd">
                <iframe name="YYUC_ca0e1e017f78eec62c054b2f3219bf17_if"
                        style="position:absolute; left:-10000px;"></iframe>
                <table style="border:none;padding:0;margin:0;width:auto;display: inline-block;">
                    <tbody>
                    <tr style="border:none;padding:0;margin:0;">
                        <td style="border:none;padding:0;margin:0;width:auto;">

                        </td>
                        <td style="border:none;padding:0;margin:0;width:auto;">
<span id="YYUC_ca0e1e017f78eec62c054b2f3219bf17_span"
      style="display:-moz-inline-box;display:inline-block;width:100px;height:32px;">
</span>
                        </td>
                        <td style="border:none;padding:0;margin:0;width:auto;">
                                                                        <span id="YYUC_ca0e1e017f78eec62c054b2f3219bf17_loadpic"
                                                                              style="display: none;"><img
                                                                                src="/@system/img/loading/18.gif"></span>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <input type="hidden"
                       name="resT08d9e827ffbba2efe4413cb064bbf847pic"
                       id="YYUC_ca0e1e017f78eec62c054b2f3219bf17_text"
                       value="">
                <script>
                    $(function () {
                        var YYUC_ca0e1e017f78eec62c054b2f3219bf17_form = window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_form = $('<form style="position: absolute;left:-10000px;" id="YYUC_ca0e1e017f78eec62c054b2f3219bf17" action="/@system/upload.html" method="post" enctype="multipart/form-data" target="YYUC_ca0e1e017f78eec62c054b2f3219bf17_if"></form>');
                        $('body').append(YYUC_ca0e1e017f78eec62c054b2f3219bf17_form);
                        YYUC_ca0e1e017f78eec62c054b2f3219bf17_form.html($('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_div').html());
                        $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_div').remove();
                        window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_resize = function () {
                            if ($('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_span').is(':hidden')) {
                                YYUC_ca0e1e017f78eec62c054b2f3219bf17_form.hide();
                            } else {
                                YYUC_ca0e1e017f78eec62c054b2f3219bf17_form.show();
                                var YYUC_ca0e1e017f78eec62c054b2f3219bf17_offset = $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_span').offset();
                                YYUC_ca0e1e017f78eec62c054b2f3219bf17_form.css('left', YYUC_ca0e1e017f78eec62c054b2f3219bf17_offset.left).css('top', YYUC_ca0e1e017f78eec62c054b2f3219bf17_offset.top);
                            }

                        };
                        setInterval(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_resize, 55);
                        var YYUC_ca0e1e017f78eec62c054b2f3219bf17pic = $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17').find('input[name="YYUC_UPLOAD_file"]');
                        YYUC_ca0e1e017f78eec62c054b2f3219bf17pic.css('opacity', 0);
                        YYUC_ca0e1e017f78eec62c054b2f3219bf17pic.change(function () {
                            var thefiles = $(this).val().replaceAll('\\', '/').split('/');
                            var filename = thefiles[thefiles.length - 1];
                            //后缀校验
                            var needsuffixs = ',png,jpeg,jpg,gif,bmp,'.toLowerCase();
                            var suffixs = filename.split('.');
                            if (needsuffixs.indexOf((',' + suffixs[suffixs.length - 1] + ',').toLowerCase()) == -1) {
                                if (alert) {
                                    alert('文件格式不被允许', $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17'), 1, 'YYUC_ca0e1e017f78eec62c054b2f3219bf17');
                                }
                            } else {
                                $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_name').html(filename);
                                window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd = 0;
                                YYUC_ca0e1e017f78eec62c054b2f3219bf17_process()
                                $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17').submit();
                                $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_loadpic').show();

                                $('iframe[name="YYUC_ca0e1e017f78eec62c054b2f3219bf17_if"]').unbind('load').load(function () {
                                    if (!window.YYUC_ca0e1e017f78eec62c054b2f3219bf17) {
                                        $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_loadpic').hide();
                                        $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_bfb').html('');
                                        if (alert) {
                                            alert('网络连接超时或文件大小超出', $('#ttid'), 3, 'YYUC_ca0e1e017f78eec62c054b2f3219bf17');
                                            clearTimeout(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17jdproc);
                                        }
                                    }
                                });
                            }
                        });

                    });
                    function YYUC_ca0e1e017f78eec62c054b2f3219bf17_process() {
                        if (window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd < 99) {
                            var nexttime = parseInt(Math.sqrt(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd) * 100) * 2;
                            window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd = window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd + 1;
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_bfb').html(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd + '%');
                            window.YYUC_ca0e1e017f78eec62c054b2f3219bf17jdproc = setTimeout(function () {
                                YYUC_ca0e1e017f78eec62c054b2f3219bf17_process();
                            }, nexttime);
                        } else {
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_bfb').html('');
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_loadpic').hide();
                            if (alert) {
                                alert('网络连接超时或文件大小超出', $('#ttid'), 3, 'YYUC_ca0e1e017f78eec62c054b2f3219bf17');
                            }
                        }
                    }
                    function YYUC_ca0e1e017f78eec62c054b2f3219bf17_success(url, key) {
                        $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_del').show();
                        window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_jd = 100;
                        $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_bfb').html('100%');
                        $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_loadpic').hide();
                        clearTimeout(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17jdproc);
                        var oldkey = $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_text').val();
                        if (oldkey.indexOf('@-@') != -1) {
                            var oldkey2 = oldkey.split('@-@');
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_text').val(key + '@-@' + oldkey2[1]);
                        } else if (oldkey.indexOf('/') == 0) {
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_text').val(key + '@-@' + oldkey);
                        } else {
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_text').val(key);
                        }
                        window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_upimg = $('<img id="YYUC_ca0e1e017f78eec62c054b2f3219bf17_realpic" src="' + url + '"/>');
                        $('#picsethere').html('').append(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17_upimg);
                        if (hidepicname) {
                            hidepicname(url, $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17'), 'YYUC_ca0e1e017f78eec62c054b2f3219bf17');
                        }
                    }
                    function YYUC_ca0e1e017f78eec62c054b2f3219bf17_failure(size, type) {
                        if (alert) {
                            if (type == 2) {
                                alert('文件大小为：' + size + 'K，超出了600K的限制,上传失败！', $('#ttid'), 2, 'YYUC_ca0e1e017f78eec62c054b2f3219bf17');
                            } else {
                                alert('文件上传发生未知错误', $('#ttid'), 4, 'YYUC_ca0e1e017f78eec62c054b2f3219bf17');
                            }
                            clearTimeout(window.YYUC_ca0e1e017f78eec62c054b2f3219bf17jdproc);
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_bfb').html('');
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_name').html('');
                            $('#YYUC_ca0e1e017f78eec62c054b2f3219bf17_loadpic').hide();
                        }
                    }
                </script>
            </div>
            <p id="upload-tip" class="upload-tip">请事先调整好图片尺寸</p>

            <p id="imgArea" class="cover-bd" style="display: none;">
                <img src="" id="img">
                <a href="javascript:;" class="vb cover-del"
                   id="delImg">删除</a>
            </p>
        </div>
    </div>
</div>
<a id="desc-block-link" href="javascript:void(0);" class="url-link block"
   style="display: none;">添加摘要</a>

<div id="desc-block" style="" class="control-group">
    <label class="control-label">摘要</label> <span class="help-inline">(不能超过120个字)</span>

    <div class="controls">
        <textarea name="summary" id="desc" class="msg-txta"
                  placeholder="摘要可以为空"></textarea>
    </div>
</div>
<div class="control-group">
    <label class="control-label">正文</label> <span
        class="maroon">*</span><span
        class="help-inline">(正文和链接地址至少填写一项)</span>

    <div class="controls">
        <div class="ke-container ke-container-default"
             style="width: 498px;">
            <div style="display:block;" class="ke-toolbar"
                 unselectable="on"><span class="ke-inline-block ke-outline"
                                         data-name="bold" title="粗体(Ctrl+B)"
                                         unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-bold"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="italic"
                    title="斜体(Ctrl+I)" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-italic"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="underline"
                    title="下划线(Ctrl+U)" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-underline"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline"
                    data-name="insertorderedlist" title="编号"
                    unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-insertorderedlist"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline"
                    data-name="insertunorderedlist" title="项目符号"
                    unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-insertunorderedlist"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="fontname"
                    title="字体" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-fontname"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="fontsize"
                    title="文字大小" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-fontsize"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="link"
                    title="超级链接" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-link"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="unlink"
                    title="取消超级链接" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-unlink"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="image"
                    title="图片" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-image"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline"
                    data-name="removeformat" title="删除格式" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-removeformat"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="forecolor"
                    title="文字颜色" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-forecolor"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline"
                    data-name="hilitecolor" title="文字背景"
                    unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-hilitecolor"
                    unselectable="on"></span></span><span
                    class="ke-inline-block ke-outline" data-name="emoticons"
                    title="插入表情" unselectable="on"><span
                    class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ke-icon-emoticons"
                    unselectable="on"></span></span></div>
            <div style="display: block; height: 319px;" class="ke-edit">
                <iframe class="ke-edit-iframe" hidefocus="true"
                        frameborder="0"
                        style="width: 100%; height: 319px;"></iframe>
                <textarea class="ke-edit-textarea" hidefocus="true"
                          style="width: 100%; height: 319px; display: none;"></textarea>
            </div>
            <div class="ke-statusbar"><span
                    class="ke-inline-block ke-statusbar-center-icon"></span><span
                    class="ke-inline-block ke-statusbar-right-icon"
                    style="visibility: hidden;"></span></div>
        </div>
        <textarea style="width: 498px; height: 360px; display: none;"
                  width="498px" height="360px"
                  name="fT08d9e827ffbba2efe4413cb064bbf847g"
                  id="fg"></textarea><input type="hidden"
                                            relobj="kindeditor" rel="yyuc"
                                            editorid="fg"
                                            value="{langType:&quot;zh-cn&quot;,allowImageUpload:true,allowFlashUpload:true,allowMediaUpload:true,allowFileManager:false,items:kindeditor_item0}">
    </div>
</div>
<a id="url-block-link" href="javascript:void(0);" class="url-link block"
   style="display: none;">添加来源</a>

<div id="url-block" style="" class="control-group">
    <label class="control-label">地址</label> <span class="help-inline">(请输入正确的URL链接格式)</span>

    <div class="controls">
        <input type="text" id="url" class="span5" value=""
               style="width: 482px;" name="source_url">
    </div>
</div>
<div class="control-group">
    <div class="controls">
        <button id="save-btn" type="button" onclick="savedate();"
                class="btn btn-primary btn-large">保存
        </button>
        <button id="cancel-btn" type="button" class="btn btn-large">取消
        </button>
    </div>
</div>

<input id="uid" name="uid" type="hidden" value="15065">
<input id="action" name="action" type="hidden" value="add">
</form>
</div>
<span class="abs msg-arrow a-out" style="margin-top: 0px;"></span>
<span class="abs msg-arrow a-in" style="margin-top: 0px;"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="portlet-title">
    <div class="actions btn-set">
        <a href="javascript:history.go(-1);" class="btn default"><i class="fa fa-angle-left"></i> 返回</a>
        <a href="javascript:location.reload();" class="btn green"><i class="fa fa-reply"></i> 重置</a>
        <button type="button" id="btnSave" class="btn blue"><i class="fa fa-check"></i> 保存</button>
    </div>
</div>
</div>
<input type="hidden" id="id" name="id" value="${data.id}">
</form>
</div>
</div>
</div>
</div>
</div>
<jsp:include page="../common/footer.jsp"/>
<script>
    var operType = '${operType}';
    var editor, form;
    jQuery(document).ready(function () {
        form = $("form").Validform({
            tiptype: 3,
            postonce: true,
            showAllError: true,
            callback: function (data) {
                if (data && data.statusCode === 200) {
                    /* var id = $("#id");
                     if(!id.val())
                     id.val(data.id);
                     if(confirm("保存成功，是否跳转到智库管理页面？")) */
                    window.location.href = _path + "/article/init/" + operType + "/" + operType;
                } else {
                    alert("保存失败！");
                }
            }
        });
        $("button[id='btnSave']").click(function (e) {
// 		var context = editor.getData();
            var context = $('#editor').html();
            if (!/[\w\W]+/.test(context)) {
                alert("内容不能为空");
                return;
            }
            $("#context").val(context);
            form.ajaxPost(false, true, _path + "/article/save");
        });
//     editor = CKEDITOR.replace('context');
    });
</script>
</body>
</html>